package com.lanfan.service.impl;

import com.lanfan.entity.Notes;
import com.lanfan.entity.NotesExample;
import com.lanfan.mapper.NotesMapper;
import com.lanfan.service.NotesService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: lanfan
 * @parameter:
 * @return：
 * @description:
 * @author: WXP
 * @create: 2024-10-11 15:37
 * @version: 1.0
 **/
@Service
public class NotesServiceImpl implements NotesService {

    @Resource
    private NotesMapper noteSMapper;


    @Override
    public void createNote(Notes note) {
        noteSMapper.insert(note);
    }

    @Override
    public void deleteNote(String noteId) {
        noteSMapper.deleteByPrimaryKey(Integer.valueOf(noteId));
    }

    @Override
    public List<Notes> getNoteByUserId(String userId) {
        NotesExample notesExample = new NotesExample();
        NotesExample.Criteria criteria = notesExample.createCriteria();
        criteria.andUserIdEqualTo(Integer.parseInt(userId));
        return noteSMapper.selectByExample(notesExample);
    }


}
